/**
 * Copyright 2007-2010 非也
 * All rights reserved. 
 * 
 * This library is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License v3 as published by the Free Software
 * Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along
 * with this library; if not, see http://www.gnu.org/licenses/lgpl.html.
 *
 */
package org.fireflow2.designer.eclipse.commands.service.java;

import org.eclipse.core.resources.IProject;
import org.fireflow.model.binding.impl.ServiceBindingImpl;
import org.fireflow.model.servicedef.ServiceDef;
import org.fireflow.service.java.JavaService;
import org.fireflow2.designer.eclipse.commands.service.AbstractServiceCreationWizard;
import org.fireflow2.designer.eclipse.modelwrapper.basic.ServiceDefWrapper;

/**
 *
 * @author 非也 nychen2000@163.com
 * Fire Workflow 官方网站：www.firesoa.com 或者 www.fireflow.org
 *
 */
public class JavaServiceCreationWizard extends AbstractServiceCreationWizard {
	private static final String ConfigJavaServicePage = "ConfigJavaServicePage";
	private static final String ConfigJavaServiceBindingPage = "ConfigOperationBindingPage";
	private static final String ConfigInputOutputBindingPage = "ConfigInputOutputBindingPage";

	
	public JavaServiceCreationWizard(IProject project){
		this.setForcePreviousAndNextButtons(true);
		this.setWindowTitle("服务组件配置");
		ServiceDef svcDef = new JavaService();
		serviceDefWrapper = new ServiceDefWrapper(svcDef);
		serviceDefWrapper.setProject(project);
		
		serviceBinding = new ServiceBindingImpl();
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
	 */
	@Override
	public boolean performFinish() {
		if (this.serviceDefWrapper!=null){
			serviceBinding.setServiceId(serviceDefWrapper.getID());
			return true;
		}
		return false;
	}

	
	public void addPages() {
		ConfigJavaServicePage enterClassNameBeanNamePage = new ConfigJavaServicePage(ConfigJavaServicePage);
		this.addPage(enterClassNameBeanNamePage);
		
		ConfigOperationBindingPage configJavaServiceBindingPage = new ConfigOperationBindingPage(ConfigJavaServiceBindingPage);
		this.addPage(configJavaServiceBindingPage);
		
		ConfigInputOutputBindingPage configInputOutputPage = new ConfigInputOutputBindingPage(ConfigInputOutputBindingPage);
		this.addPage(configInputOutputPage);
	}
}
